import request from '@/utils/request'

// 获取商品规格列表 (分页)
export function getProductSpecList(params) {
  return request({
    url: '/productSpec/list',
    method: 'GET',
    params
  })
}

// 根据ID获取规格详情
export function getProductSpecById(id) {
  return request({
    url: `/productSpec/${id}`,
    method: 'GET'
  })
}

// 新增商品规格
export function addProductSpec(data) {
  return request({
    url: '/productSpec',
    method: 'POST',
    data
  })
}

// 更新商品规格
export function updateProductSpec(data) {
  return request({
    url: '/productSpec',
    method: 'PUT',
    data
  })
}

// 删除商品规格
export function deleteProductSpec(id) {
  return request({
    url: `/productSpec/${id}`,
    method: 'DELETE'
  })
}

// 根据商品ID获取规格列表
export function getSpecsByProductId(productId) {
  return request({
    url: `/productSpec/by-product/${productId}`,
    method: 'GET'
  })
}

